﻿using System.Collections.Generic;
using Cos.Core.Model.Membership;

namespace Cos.Module.Membership.Data
{
    public interface IMembershipRepository
    {
        MemberUser GetAuthenticationByUsername(string username, string applicationName);// throws UserNotFoundException;

        /**
         * Used to retrieve the authentication by email
         * 
         * @param email the email
         * @param applicationName the applicationName
         * @return the authenticationVo
         * @throws UserNotFoundException if the user is not found
         */
        MemberUser GetAuthenticationByEmail(string email, string applicationName);// throws UserNotFoundException;

        /**
         * Retreives a user based on it's userId and application name
         * 
         * @param userId the user id
         * @param applicationName the application name
         * @return the user if it exists
         * @throws UserNotFoundException if the user has not be found
         */
        MemberUser GetAuthenticationByPkid(string userId, string applicationName);// throws UserNotFoundException;

        /**
         * Used when the user is logged in
         * 
         * @param userId id of the user
         * @throws UserNotFoundException if the user has not be found
         */
        void OnSuccessLogin(string userId);// throws UserNotFoundException;

        /**
         * Used when the user is not able to log-in
         * 
         * @param userId id of the user
         * @throws UserNotFoundException if the user has not be found
         */
        void OnFailedlLogin(string userId);// throws UserNotFoundException;

        /**
         * Used when the user is logged out
         * 
         * @param userId id of the user
         * @throws UserNotFoundException if the user has not be found
         */
        void OnSuccessLogout(string userId);// throws UserNotFoundException;

        /**
         * Creates a new user in an application
         * 
         * @param applicationName the application to create the user for
         * @param userName the user name
         * @param password the user password
         * @param email the user email address
         * @param groups the groups to add the user to
         * @return the user identifier
         * @throws DuplicateUserException thrown if a user already exists with the same name
         */
        string CreateUser(string applicationName, string userName, string password, string email, string[] groups);// throws DuplicateUserException;

        /**
         * Modified the email address associated with an user
         * 
         * @param userId the user id
         * @param email the new email address
         * @throws UserNotFoundException if the user has not be found
         */
        void ModifyUserEmail(string userId, string email);// throws UserNotFoundException;

        /**
         * Changes a user's password
         * 
         * @param userId the user id
         * @param password the new password
         * @throws UserNotFoundException if the user has not been found
         */
        void ModifyUserPassword(string userId, string password);// throws UserNotFoundException;

        /**
         * Validates that a string matches the current password of a user
         * 
         * @param userId the user id
         * @param password the password to check
         * @return true if it matches, false otherwiser
         * @throws UserNotFoundException if the user has not been found
         */
        bool ValidateUserPassword(string userId, string password);//throws UserNotFoundException;

        /**
         * Returns the roles associated with a specific nav id
         * 
         * @param navId The nav id to get the information for
         * @return The associated roles for this nav id
         */
        IEnumerable<string> GetRolesForNavId(int navId);
    }
}
